package com.example.note2;

import android.app.Activity;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.Adapter;
import android.widget.Button;
import android.widget.TextView;

/**
 * Created by 居伦昶 on 2018/6/21.
 */

public class SelectAct extends Activity {
    private Button s_back;
    private Button s_delete;
    private TextView s_tv;
    private NotesDB notesDB;
    private SQLiteDatabase dbWriter;

    @Override
    protected void onCreate( Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.select);
        s_delete =findViewById(R.id.s_delete);
        s_back =findViewById(R.id.s_back);
        s_tv=findViewById(R.id.s_tv);
        notesDB=new NotesDB(this);
        dbWriter=notesDB.getWritableDatabase();
        s_tv.setText(getIntent().getStringExtra(NotesDB.CONTENE));
        s_delete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                deleteDate();
                finish();
            }
        });
        s_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
    public void deleteDate(){
        dbWriter.delete(NotesDB.TABLE_NAME,"_id="+getIntent().getIntExtra(NotesDB.ID,0),null);

    }
}
